﻿using System.Xml.Linq;

namespace Silent.API.LastFm.Requests
{
    public class AuthentificationTokenRequest : RequestBase<string>
    {
        public AuthentificationTokenRequest(string apiKey)
            : base(apiKey, QueryConstants.AUTH_GET_TOKEN)
        {
        }

        public override string Request()
        {
            var query = new QueryBuilder().BuildQuery(this.parameters.ToArray());
            var token = XElement.Load(query).Element("token");
            return token != null ? token.Value : null;
        }
    }
}